<%@Page Language="VB"%>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient" %>
<html><head>
<title>
DataGrid Control</title>
</head>
<body>
<span class="heading">
	DataGrid and TemplateColumn
</span>
<hr width="350" align="left"/>
<div id="outError" runat="server">&nbsp;</div>
<asp:datagrid id="dgrResult"	 
AutoGenerateColumns="False" runat="server" > 
<Columns> 
<asp:TemplateColumn HeaderText="UserID"> 
<ItemTemplate> 
<asp:Label ID="UserID" _
Text='<%# DataBinder.Eval(Container.DataItem, _
"UserID").toString()%>' 
Runat=server /> 
</ItemTemplate> </asp:TemplateColumn>
 <asp:TemplateColumn HeaderText="UserName"> 
<ItemTemplate> 
<asp:Label ID="UserName" _
Text='<%# DataBinder.Eval(Container.DataItem, _
"UserName").toString()%>' 
Runat=server /> 
</ItemTemplate> </asp:TemplateColumn>
 <asp:TemplateColumn HeaderText="FullName"> 
<ItemTemplate> 
<asp:Label ID="FullName" _
Text='<%# DataBinder.Eval(Container.DataItem, _
"FullName").toString()%>' 
Runat=server /> 
</ItemTemplate> </asp:TemplateColumn>
 <asp:TemplateColumn HeaderText="Email"> 
<ItemTemplate> 
<asp:Label ID="Email" _
Text='<%# DataBinder.Eval(Container.DataItem, _
"Email").toString()%>' 
Runat=server /> 
</ItemTemplate> </asp:TemplateColumn>
</Columns> </asp:DataGrid> 
<script language="vb" runat="server">
Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)      
   Dim myDataSet As New DataSet()
   Try
      Dim strConn As String
      Dim strSQL As String
      strConn= _
      ConfigurationSettings.appSettings("conn")
      Dim myConn As New SqlConnection(strConn)      
      strSQL = "SELECT * From "
      strSQL +=" tblUsers"
      Dim myDataAdapter As New _
	SqlDataAdapter(strSQL, myConn)
      myDataAdapter.Fill(myDataSet,  _
	strSQL)     
   Catch objError As Exception
      	outError.innerHTML = _
	"<b>* Error while " & _
	"accessing data</b>.<br />" _
          	& objError.Message & "<br />" & _
	objError.Source
      Exit Sub  
   End Try        
   dgrResult.DataSource = myDataSet
   dgrResult.DataBind()   
End Sub
</script>
</body>
</html>
  